Skip to content

unify(controlbar): Merge and move ControlBar and related code to core#2849

Open
stephanmeesters wants to merge 3 commits into
TheSuperHackers:mainfrom
stephanmeesters:unify/merge-move-controlbar
Open

unify(controlbar): Merge and move ControlBar and related code to core#2849
stephanmeesters wants to merge 3 commits into
TheSuperHackers:mainfrom
stephanmeesters:unify/merge-move-controlbar

Conversation

@stephanmeesters

@stephanmeesters stephanmeesters commented Jul 1, 2026

Copy link
Copy Markdown

Merge by rebase

Rebased and diffs checked in WinMerge. Re-applied the move with the script.

Changes to Generals

  • Added support for dynamic General's Power purchase images.
    • This is for a custom background image of the General's Power screen, used to get a general-specific background image in ZH. Not used in Generals
    • Now resizes the panel based on the size of that background image (if it exists)
  • Unified special-power shortcut handling enum (FROM_COMMAND_CENTER to FROM_SHORTCUT)
    • No runtime change
  • Let OCL timer tech buildings show rally-point controls when supported.
    • Not used in Generals, this is used for the TechReinforcementPad in ZH
  • Hid tooltip cost text for free items and science
    • Not used in Generals, a zero-cost UI item is for example switching fake/real buildings in ZH.
  • Showed building-specific max-count tooltip text.
    • Reverted to using the unit max-count text using an #ifdef
  • Adds support for a prerequisite science for a command button
    • Appears to be used for MOAB in ZH

Todo

  • Add pull id's
  • Test

@stephanmeesters stephanmeesters force-pushed the unify/merge-move-controlbar branch from 95571e0 to da28ca7 Compare July 1, 2026 11:50
@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR unifies the ControlBar subsystem by moving its header and source files from game-specific directories (Generals/Code/ and GeneralsMD/Code/) into the shared Core/ module, eliminating duplicated compilation units across game targets.

  • CMakeLists.txt changes (Core, Generals, GeneralsMD, and their device counterparts) uncomment the ControlBar files in Core and comment them out in Generals/GeneralsMD, so all three games compile the single Core copy going forward.
  • ControlBarPopupDescription.cpp is the only file with real code changes: it adds #ifdef RTS_GENERALS for building-specific max-count tooltip text, hides the cost display for free/zero-cost items, and adds a prerequisite-science check for upgrade command buttons (used by ZH's MOAB).
  • scripts/cpp/unify_move_files.py is updated to mark the ControlBar file group as already migrated (calls commented out), preventing double-application of the unify script.

Confidence Score: 5/5

Safe to merge; this is a clean build-system migration with no behavioural changes for Generals and only small, intentional ZH-specific additions.

The overwhelming majority of the diff is CMakeLists comment/uncomment lines that redirect compilation from game-specific directories to Core. The only actual code delta is in ControlBarPopupDescription.cpp, which correctly adds an RTS_GENERALS preprocessor guard for tooltip text, hides zero-cost item pricing, and adds a prerequisite-science loop for upgrade buttons — all matching the stated intent of the PR and free of logic errors.

No files require special attention. The Core ControlBarPopupDescription.cpp is the only file with real code changes and it looks correct.

Important Files Changed

Filename Overview
Core/GameEngine/CMakeLists.txt Uncomments all ControlBar headers and source files so they are compiled as part of Core; straightforward mirror of changes in the game-specific CMakeLists files.
Core/GameEngine/Source/GameClient/GUI/GUICallbacks/ControlBarPopupDescription.cpp New file in Core (migrated from Generals); adds #ifdef RTS_GENERALS for building max-count tooltip, hides cost for free items, and adds prerequisite-science check for upgrade buttons. Logic looks correct.
Generals/Code/GameEngine/CMakeLists.txt Comments out all ControlBar files previously compiled in Generals, delegating to Core; correct counterpart to the Core CMakeLists change.
GeneralsMD/Code/GameEngine/CMakeLists.txt Comments out all ControlBar files for Zero Hour as well, aligning with Core; symmetric to the Generals change.
Core/GameEngineDevice/CMakeLists.txt Uncomments W3DControlBar.cpp in Core's device layer so the rendering-specific control bar callback is compiled from Core instead of game-specific directories.
scripts/cpp/unify_move_files.py Marks ControlBar file group as already migrated (unify_file calls commented out) and comments out a prior MessageStream block; correctly prevents re-application of the move.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Core["Core/GameEngine\nCMakeLists.txt\n(ControlBar files ENABLED)"]
    CoreDev["Core/GameEngineDevice\nCMakeLists.txt\n(W3DControlBar.cpp ENABLED)"]
    GenEng["Generals/Code/GameEngine\nCMakeLists.txt\n(ControlBar files DISABLED)"]
    GenDev["Generals/Code/GameEngineDevice\nCMakeLists.txt\n(W3DControlBar.cpp DISABLED)"]
    MDEng["GeneralsMD/Code/GameEngine\nCMakeLists.txt\n(ControlBar files DISABLED)"]
    MDDev["GeneralsMD/Code/GameEngineDevice\nCMakeLists.txt\n(W3DControlBar.cpp DISABLED)"]
    CB["ControlBar\n.h/.cpp files\n(Core sources)"]
    W3D["W3DControlBar.cpp\n(Core device source)"]
    PopupNew["ControlBarPopupDescription.cpp\n(Core, new features:\n- cost hidden if free\n- prereq science check\n- #ifdef RTS_GENERALS tooltip)"]
    Core -->|"compiles"| CB
    Core -->|"compiles"| PopupNew
    CoreDev -->|"compiles"| W3D
    GenEng -.->|"delegates to Core"| CB
    GenDev -.->|"delegates to Core"| W3D
    MDEng -.->|"delegates to Core"| CB
    MDDev -.->|"delegates to Core"| W3D
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    Core["Core/GameEngine\nCMakeLists.txt\n(ControlBar files ENABLED)"]
    CoreDev["Core/GameEngineDevice\nCMakeLists.txt\n(W3DControlBar.cpp ENABLED)"]
    GenEng["Generals/Code/GameEngine\nCMakeLists.txt\n(ControlBar files DISABLED)"]
    GenDev["Generals/Code/GameEngineDevice\nCMakeLists.txt\n(W3DControlBar.cpp DISABLED)"]
    MDEng["GeneralsMD/Code/GameEngine\nCMakeLists.txt\n(ControlBar files DISABLED)"]
    MDDev["GeneralsMD/Code/GameEngineDevice\nCMakeLists.txt\n(W3DControlBar.cpp DISABLED)"]
    CB["ControlBar\n.h/.cpp files\n(Core sources)"]
    W3D["W3DControlBar.cpp\n(Core device source)"]
    PopupNew["ControlBarPopupDescription.cpp\n(Core, new features:\n- cost hidden if free\n- prereq science check\n- #ifdef RTS_GENERALS tooltip)"]
    Core -->|"compiles"| CB
    Core -->|"compiles"| PopupNew
    CoreDev -->|"compiles"| W3D
    GenEng -.->|"delegates to Core"| CB
    GenDev -.->|"delegates to Core"| W3D
    MDEng -.->|"delegates to Core"| CB
    MDDev -.->|"delegates to Core"| W3D
Loading

Reviews (2): Last reviewed commit: "unify(controlbar): Move ControlBar files..." | Re-trigger Greptile

@stephanmeesters stephanmeesters added Gen Relates to Generals ZH Relates to Zero Hour Unify Unifies code between Generals and Zero Hour labels Jul 1, 2026
@xezon xezon added ZH Relates to Zero Hour and removed ZH Relates to Zero Hour labels Jul 1, 2026
@xezon xezon added this to the Code foundation build up milestone Jul 1, 2026

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed a Base Generals HUD regression where the Generals Powers shortcut bar could disappear

How did Generals regress?

descrip.concat( TheGameText->fetch( "TOOLTIP:TooltipCannotBuildUnitBecauseMaximumNumber" ) );
if ( thingTemplate->isKindOf( KINDOF_STRUCTURE ) )
{
descrip.concat( TheGameText->fetch( "TOOLTIP:TooltipCannotBuildBuildingBecauseMaximumNumber" ) );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tool tip string does not exist in Generals and therefore will show placeholder text now.

@stephanmeesters stephanmeesters Jul 3, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will now show the "unit already exists" text again using #ifdef RTS_GENERALS (see 2nd commit)

win = TheWindowManager->winGetWindowFromId( nullptr, TheNameKeyGenerator->nameToKey( "GeneralsExpPoints.wnd:GenExpParent" ) );
if(win)
{
win->winSetEnabledImage(0,m_powerPurchaseImage);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m_powerPurchaseImage will be null here in Generals. Is this ok?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm putting nullptr in win->winSetEnabledImage is safe

@stephanmeesters

Copy link
Copy Markdown
Author

How did Generals regress?

This was already fixed in #2680, removed from description

@stephanmeesters stephanmeesters force-pushed the unify/merge-move-controlbar branch from da28ca7 to acdcd4d Compare July 3, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Unify Unifies code between Generals and Zero Hour ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants